﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cxx.BLL;
using Cxx.Common;

namespace Cxx.OrderManagerSys
{
    public partial class StackManage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
            //    BindData();
            //}
        }

        private void BindData()
        {
            string condition = MyWebHelper.SelectKey(pnlSearch, out _);
            var list = Stock.GetListForPage(condition, pager.CurrentPageIndex, pager.PageSize, out int recordCount);
            pager.RecordCount = recordCount;
            rptOrderList.DataSource = list;
            rptOrderList.DataBind();
        }

        protected void pager_PageIndexChange(object sender, EventArgs e)
        {
            BindData();
        }

        protected void btBrowse_Click(object sender, EventArgs e)
        {
            pager.CurrentPageIndex = 1;
            BindData();
        }

        protected void btExport_Click(object sender, EventArgs e)
        {
            string url = $"http://{Request.Url.Host}:{Request.Url.Port}/StockExport.aspx?name={txtReceiver.Text}";
            JScript.RedirectInNewWindow(Page, url);
        }
    }
}